import {Component,OnInit,ViewChild} from '@angular/core';
import { PageModel } from "../../../../model/page-model";
import { ModalDirective } from 'ng2-bootstrap/modal';
import { flyIn } from '../../../../animations/fly-in';
import { MyHttp } from '../../../../service/MyHttp';

@Component({
  selector: 'ordinaryorder',
  templateUrl: './ordinaryorder.component.html',
  styleUrls: ['./ordinaryorder.component.css'],
  animations: [
    flyIn
  ]
})
export class Ordinaryorder implements OnInit{
  @ViewChild('myModal') public myModal:ModalDirective;
  pageModel = new PageModel();
  page:number = 1;
  orderdata:any;
  usertelephone:number;
  constructor(private myHttp:MyHttp) {}
  ngOnInit() {   
    this.getData();
  }


  getData(){
    this.myHttp.post('order/findByPage?page='+this.page,{}).subscribe(res=>{
      //console.log(res)
      if(res.errorCode==0){
        this.orderdata = res.message.data;      
        this.pageModel.setPage({'iTotalRecords':res.message.total});
      }
     
    },err=>console.log(err));
  }

  getSearchdata(){
      this.myHttp.post('order/findByTel',{
        "user_telephone" :this.usertelephone
      }).subscribe(res=>{
        //console.log(res)
      if(res.errorCode==0){
        this.orderdata = res.message; 
      }
     
    },err=>console.log(err));
  }
  


}

